package com.wanlian.router.ui.me.message;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.smart.android.image.ImageLoader;
import com.smart.android.ui.tools.MyNiuBAdapter;
import com.wanlian.router.R;
import com.wanlian.router.bean.Message;
import com.wanlian.router.utils.Utils;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Hyu on 2018/8/31.
 * Email: fvaryu@qq.com
 */
public class SystemNoticeAdapter extends MyNiuBAdapter<Message> {

    public SystemNoticeAdapter(Context context, List<Message> mTs) {
        super(context, mTs);
    }

    @Override
    public int layout() {
        return R.layout.layout_item_message;
    }

    @Override
    public MyViewHolder<Message> holder(View view) {
        return new SystemNoticeHolder(view);
    }

    class SystemNoticeHolder extends MyViewHolder<Message> {

        @BindView(R.id.image_read)
        ImageView mImageRead;
        @BindView(R.id.image_logo)
        ImageView image_logo;
        @BindView(R.id.tv_title)
        TextView mTitle;
        @BindView(R.id.tv_synopsis)
        TextView mSysnopsis;

        @BindView(R.id.tv_time)
        TextView mTime;

        public SystemNoticeHolder(View view) {
            super(view);
        }

        @Override
        public void setData(int i, Message message) {
            if (message.getId() == 0) {
                image_logo.setImageResource(R.drawable.drawable_sys_message);
            }else {
                image_logo.setImageResource(R.drawable.drawable_normal_message);
            }
            if (message.getNoticeTime() > 0) {

                mTime.setText(Utils.getDate(message.getNoticeTime()));
            }else {
                mTime.setText("");
            }



            mTitle.setText(message.getTitle());
            mSysnopsis.setText(message.getContent());

            if (message.isHasLook()) {
                mImageRead.setVisibility(View.GONE);
            }else {
                mImageRead.setVisibility(View.VISIBLE);
            }


        }
    }
}
